﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>跟进记录管理</title>
    <#--要在script前引入-->
    <#include "../common/link.ftl">
    <script>
        $(function () {
            $('.btn-input').click(function () {

                //清除模态框中表单里的旧有数据
                $('#traceForm')[0].reset();
                //设置标题

                var data = $(this).data('json');
                console.log(data);
                if(data){
                    $('input[name="customer.id"]').val(data.customerId);
                    $('input[name=name]').val(data.customerName);
                    $('input[name=traceTime]').val(data.traceTime);
                    $('input[name=traceDetails]').val(data.traceDetails);
                    $('select[name="traceResult"]').val(data.traceResult);
                    $('select[name="traceType.id"]').val(data.traceTypeId);
                    $('textarea[name="remark"]').val(data.remark);
                }


                $('#traceModal').modal('show');
            });


            $('.traceSubmit').click(function () {
                $('#traceForm').ajaxSubmit(function (data) {
                    if(data.success){
                        $.messager.confirm("温馨提示",data.msg,function () {
                            window.location.reload();
                        });
                    }else {
                        $.messager.alert("温馨提示",data.msg);
                    }
                });
            });


        })
    </script>


</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu = "customerTraceHistory">
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>跟进管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/customerTraceHistory/list" method="post">
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入客户姓名/手机">
                    </div>

                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>

                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户名称</th>
                            <th>客户电话</th>
                            <th>跟进时间</th>
                            <th>跟进记录</th>
                            <th>交流方式</th>
                            <th>跟进结果</th>
                            <th>备注</th>
                            <th>录入人</th>
                            <th>录入时间</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as customerTraceHistory>
                            <tr>
                                <td>${customerTraceHistory_index+1}</td>
                                <td>${customerTraceHistory.customer.name}</td>
                                <td>${customerTraceHistory.customer.tel}</td>
                                <td>${customerTraceHistory.traceTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                <td>${customerTraceHistory.traceDetails}</td>
                                <td>${customerTraceHistory.traceType.title}</td>
                                <td>${customerTraceHistory.traceResultName}</td>
                                <td>${customerTraceHistory.remark}</td>
                                <td>${customerTraceHistory.inputUser.name}</td>
                                <td>${customerTraceHistory.inputTime?string('yyyy-MM-dd HH:mm:ss')}</td>
                                <td>
                                    <a data-json='${customerTraceHistory.jsonData}' class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>

                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<!---跟进编辑--->
<#--跟进历史-->
<div class="modal fade" id="traceModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">跟进</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTraceHistory/saveOrUpdate" method="post" id="traceForm">
                <#--新增,新增跟进历史没有ID,客户应该要有ID,不然就不知道当前是哪个客户的跟进历史-->
                    <input type="hidden" name="customer.id"/>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">客户姓名：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" readonly name="name"/>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">跟进时间：</label>
                        <div class="col-lg-6 ">
                            <input type="text" class="form-control datepicker"  name="traceTime" <#--onfocus="WdatePicker()"--> >
                            <script>
                                $('.datepicker').datepicker({

                                    language: 'zh-CN',
                                    autoclose: true,
                                    todayHighlight: true, // 今天时间高亮
                                    format: 'yyyy-mm-dd',
                                    endDate:new Date() // 今天之后的日期都不可以选择

                                });
                            </script>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">跟进记录：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="traceDetails"
                                   placeholder="请输入跟进记录"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">交流方式：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="traceType.id">
                            <#list traceTypes as traceType>
                                <option value="${traceType.id}">${traceType.title}</option>
                            </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">跟进结果：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="traceResult">
                                <option value="3">优</option>
                                <option value="2">中</option>
                                <option value="1">差</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">备注：</label>
                        <div class="col-lg-6">
                            <textarea type="text" class="form-control" name="remark"></textarea>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary traceSubmit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
